home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows4 / splash.zip / SPLASH.TXT < prev    next >
Text File  |  1992-03-15  |  6KB  |  133 lines

  1.  
  2.     2/10/92
  3.  
  4.     SPLASHSCREEN DEMO
  5.  
  6.     Files:   Splash.pas - splashscreen unit source
  7.                 Splash.res - splashscreen bitmap resource
  8.                 Zwindow.pas - generic demo program
  9.                 Zilch.res -resource file for Zwindow.pas
  10.                 Splash.txt - this file  
  11.         
  12.     This small project grew out of looking at the TPW bitmap that
  13.     pops up every time you start the program. It is my understanding
  14.     that Object Graphics has a method that creates this type of splash-
  15.     screen, but rather than buy a library to accomplish this, I hacked
  16.     around until I came up with something that worked. The result is 
  17.     the unit contained in SPLASH.PAS, which pops up a borderless
  18.     bitmap window for ten seconds when your program starts. The 
  19.     window is modeless to the extent that it does not halt tasks in 
  20.     other currently executing programs, but greys out the parent 
  21.     program and does not allow the user to close it for the ten 
  22.     seconds it is onscreen. If the user clicked on the greyed parent
  23.     program, he could actually access it while the splashscreen is 
  24.     visible, but the fact that the parent program appears inactive
  25.     would discourage most users from doing so. This is probably
  26.     not very memory efficient(as a sizable bitmap resource has 
  27.     to be loaded into memory every time the parent program
  28.     executes) but it is quite slick and professional looking and is 
  29.     ideal for a shareware announcement. I have to mention that it
  30.     drives me crazy that some shareware programmers use timed 
  31.     system modal dialog boxes that bring ALL Windows processes 
  32.     to a halt while their announcement displays. A few times I have
  33.     loaded these programs while downloading remote data or in the
  34.     midst of DDE processes and have lost data (it doesn't exactly 
  35.     make me want to run for my checkbook and register their programs).
  36.     I think this splashscreen method is much more considerate of your
  37.     end user.
  38.  
  39.     ABOUT ZWINDOW.PAS
  40.     This is a generic TWindow descendent that does nothing except display the
  41.     splashscreen. It has a menu with an exit command and an about dialog. I
  42.     included this program as a demo of how to add the splashscreen object to
  43.     your existing programs.  Since the splashscreen is a parentless popup 
  44.     window, the only way you can keep it from being overlapped by the parent 
  45.     window is to call it in between the TApplication.Init and .Run methods :
  46.                
  47.         var
  48.                                   ZApp : ZilchApp;
  49.  
  50.                                 begin
  51.                                     ZApp.Init('ZilchApp');
  52.       {this inits the splashscreen object}
  53.                                   Application^.MakeWindow(New(PPicWindow, Init(nil, ws_Popup 
  54.               or ws_visible and not ws_OverlappedWindow)));
  55.                                    ZApp.Run;
  56.                                    ZApp.Done;
  57.                                end.    
  58.     The NIL statement in the splashscreen's init method registers it as a 
  59.     parentless popup that technically is owned by the application but can act 
  60.     independently of it. A normal child window would have a "@self" statement
  61.     in that position. The _ws parameters define it's behavior and appearance
  62.     and are described (in not very much detail) in the TPW Programmer's Ref. 
  63.                   Note: I have tried dozens of combinations of _ws parameters and
  64.     this was the only one that gave me the desired results. I hope some of you
  65.     will fool around with this a little more- if you come up with other settings
  66.     that work, please let me know.
  67.     Other than this init statement, all you have to do to use the splashscreen
  68.     in your program is to add it to your USES clause.
  69.  
  70.     ABOUT SPLASH.PAS
  71.  
  72.     {TPicWindow}
  73.     TPicWindow.Init(AParent : PWindowsObject; AStyle : LongInt);
  74.                  Begin
  75.         TWindow.Init(AParent,'');
  76.          with Attr do
  77.           begin
  78.                 Style := AStyle;
  79.                X := 110; Y := 100; W := 390; H := 255;
  80.       end;
  81.       hOpenBmp := LoadBitmap(HInstance,id_OpenBmp);
  82.     End;
  83.  
  84.     The TpicWindow constructor contains other parmeters that affect
  85.     it's appearance. Using the AStyle:LongInt parameter allows you
  86.     to access a child window's ws_style field to change it's width, height, 
  87.     (W,H) and the location at which it will open(X,Y).  When you change 
  88.     the bitmap resource, be sure to change W and H to the dimensions 
  89.     of the new bitmap. The final statement loads the bitmap itself.     
  90.     
  91.  
  92.     {WM_Timer}
  93.     procedure TpicWindow.WMTimer;
  94.         Begin
  95.              DeleteObject(hOpenBmp);
  96.              KillTimer(hWindow, timer_ID);
  97.            TWindow.CloseWindow;
  98.         End;
  99.  
  100.      TPicWindow initializes  a timer  in it's Setup Window method:
  101.     
  102.           SetTimer(hWindow, timer_ID, 10000, nil);
  103.     The third parameter( 10000 ) represents 10000 milleseconds, roughly 10
  104.     seconds.  By using this statement, you can execute a function when 
  105.     Windows returns a WM_Timer message to the window( hWindow) at
  106.     the interval (10000) stated in SetTimer. Here, it closes TPicWindow,
  107.     deletes the bitmap resource and and kills the timer itself (The timer is
  108.     a global resource that will continue to take up memory if not deleted):
  109.         
  110.     Paint
  111.     The paint method is an abbreviated version of the one contained in
  112.     TWindow that can display bitmaps of up to 16 colors. A 256 color 
  113.     bitmap would not display properly here because of the lack of a 
  114.     palette handling method.
  115.  
  116.     Changing the Bitmap-this must be done on the .res file itself with
  117.     a resource editor. If you rename the resource, you also have to 
  118.     change the id_bitmap statement.
  119.  
  120.     Note : The GetWindowClass and GetClassName functions are 
  121.     included for compatibility with the Windows MDI interface. They
  122.     are not needed for non-MDI apps like the sample program.
  123.  
  124.     Enjoy
  125.  
  126.     Scott Hanrahan[70144,3033]
  127.  
  128.     P.S. -to give credit where due, I would like to mention two books that
  129.     have been a great help to me in this and other projects: Turbo Pascal
  130.     for Windows 3.0 Programming by Tom Swan, and Programming
  131.     Windows by Charles Petzold  
  132.  
  133.